New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More

@colony/colony-js-utils

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@colony/colony-js-utils

Utilities for Colony JS packages

1.12.0
latest
Version published
Weekly downloads
46
1050%
Maintainers
7
Weekly downloads
 
Created

colonyJS Utilities

Utilities for colonyJS packages.

Installation

yarn add @colony/colony-js-utils

Usage

import { raceAgainstTimeout } from '@colony/colony-js-utils';

class MyClass {
    async somethingVerySlow() {
        return mySlowPromise();
    }
    async doSomethingCoolAsync() {
        // Will either return the result of `somethingVerySlow()` or throw throw an error on timeout
        return raceAgainstTimeout(this.somethingVerySlow(), 30000);
    }
    async doSomethingElse() {
        // Will do something on timeout, e.g. remove an event listener
        return raceAgainstTimeout(
            this.somethingVerySlow(),
            30000,
            () => this.removeEventListener('something'),
        );
    }
}

Contributing

This package is part of the colonyJS monorepo.

Please read our contributing guidelines.

FAQs

Package last updated on 21 May 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts